﻿CC := gcc
C := gcc

DEFINED := -DXP_UNIX=1 -DMOZ_X11=1 -D_X86_=1 -D__MINGW32__=1
OPT := -g
#OUT := $(shell pwd)/build/
OUT := ./build/

SOURCES = $(wildcard *.cpp)
SOURCES += $(wildcard sqlite3/*.c)
SOURCES += $(wildcard htmlcxx/*.cc)

OBJS := $(subst .cpp,.o,$(SOURCES))
OBJS := $(subst .cc,.o,$(OBJS))
OBJS := $(subst .c,.o,$(OBJS))
OBJS += uuid.o

OBJS2 := $(subst sqlite3/,,$(OBJS))
OBJS2 := $(subst htmlcxx/,,$(OBJS2))

all: $(OBJS)
	$(CC) -shared -fPIC $(foreach n,$(^F),$(OUT)$(n)) -luuid -o npmydn.so
	cp npmydn.so /usr/lib/mozilla/plugins/libnpmydn.so   	
	
diff: localstorage.o mydn.o mydnapp.o storage.o uuid.o
	$(CC) -shared -fPIC $(foreach n,$(OBJS2),$(OUT)$(n)) -luuid -o npmydn.so 
	cp npmydn.so /usr/lib/mozilla/plugins/libnpmydn.so
	
%.o: %.cpp %.h
	$(CC) $(OPT) $(DEFINED) -c $< -o $(OUT)$@   

uuid.o: uuid.cc 
	$(CC) $(OPT) $(DEFINED) -luuid -c $< -o $(OUT)$@

sqlite3/%.o: sqlite3/%.c
	$(C) -c $< -o $(OUT)$(@F)

htmlcxx/%.o: htmlcxx/%.cc
	$(CC) -c $< -o $(OUT)$(@F)

clean:
	rm -f $(OUT)*
	rm /usr/lib/mozilla/plugins/libnpmydn.so

